package org.dbwebx.flex.delegate.impl
{

	import mx.collections.ArrayCollection;
	import mx.rpc.events.ResultEvent;
	
	import org.dbwebx.flex.common.event.BundleEvent;
	import org.dbwebx.flex.delegate.impl.base.BundleServiceBase;
	import org.swizframework.Swiz;

	[Bindable]
	/**
	 * The <code>BundleService</code> implementation.
	 * @author Izzet_Mustafayev
	 */
	public class BundleService extends BundleServiceBase {

		public function BundleService()
		{
			super();
			//import org.dbwebx.flex.delegate.impl.base.BundleServiceBase;
		}
		
		/**
		 * Override default list success method handler.
		 * @param result the <code>ResultEvent</code>
		 * @param args the args to be passed to callback function
		 */
		override protected function listSuccessHandler(result:ResultEvent, ... args:Array):void
		{
			super.listSuccessHandler(result, args);
			if (result)
			{
				var bundles:ArrayCollection=ArrayCollection(result.result);
				var evt:BundleEvent=null;
				if (args && args.length > 0)
				{
					evt=new BundleEvent(args[0]);
				}
				if (!evt)
				{
					evt=new BundleEvent(BundleEvent.B_LIST_LOADED_EVT);
				}
				evt.bundles=bundles;
				Swiz.dispatchEvent(evt);
			}
		}
		
		override protected function persistSuccessHandler(result:ResultEvent, ... args:Array):void
		{
			super.persistSuccessHandler(result, args);
			dataChanged(operationpersist);
			clearAllCache();
		}
		
		
	}
}